Skip to content

Conversation

@iwoplaza
Copy link
Collaborator

@iwoplaza iwoplaza commented Sep 26, 2025

Changes:

  • Track referentiality of snippets (and their address space)
  • Generate pointer types for shell-less arguments if the passed-in values are referential
  • Forbid assignment of references
  • Not allowing references to be returned from a function (unless it’s a reference to something define in that function)
  • Make JS const statements be pointers if they take in a referential type (let statements)
  • Treat JS const statements with naturally non-referential types to be WGSL const 🎉
  • Track constant expressions

TODO:

  • Rename 'ref' to 'origin' to not confuse with the upcoming explicit pointers (refs)
  • Make implicit pointers (e.g.: const some = layout.$.data) local to functions, and not leak into shell-less functions signatures. This ensures that a function doesn't accidentally have access to a value it shouldn't have access to.
  • Check if Disco got fixed
  • Automatically deref implicit pointers in dualImpl

Reference assignment errors:

image

Invalid 'let' statement errors:
image

@github-actions
Copy link

github-actions bot commented Sep 26, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@ec4fc64301cec8061f44c53b20af90dbc40d4649
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@ec4fc64301cec8061f44c53b20af90dbc40d4649
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@ec4fc64301cec8061f44c53b20af90dbc40d4649

benchmark
view benchmark

commit
view commit

@iwoplaza iwoplaza marked this pull request as ready for review October 7, 2025 14:45
@aleksanderkatan
Copy link
Contributor

aleksanderkatan commented Oct 8, 2025

Something weird happened to the vaporrave example, some of the effects seem to have disappeared.

Also, Slime Mold 3D throws when switching to another example, but this might have been the case before.

Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

Some of my old comments got lost in the "hidden items".

computeLayout.$.inState[currentId].mass <
computeLayout.$.inState[otherId].mass
) {
const current = computeLayout.$.inState[currentId];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still is weird to me that this translates to a pointer. It makes sense in JS though. This may just be me coming from C, t[i] being equivalent to *(t+i).

@iwoplaza iwoplaza added this to the 0.9.0 milestone Nov 13, 2025
@iwoplaza iwoplaza linked an issue Nov 13, 2025 that may be closed by this pull request
Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's goooo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Explicit refs and derefs

3 participants